float die_rate = 0.9;
float corrupt_rate = 0.9;
int debug = 1;

using namespace std;

int SendTo(int fd, void *buf, int len, int flags, sockaddr *to, int addr_len)
{
	if ((double)rand()/RAND_MAX > die_rate)
	{
		if (debug)
			cout << "Packet died on the wire\n";
		return len;
	}

	if ((double)rand() / RAND_MAX > corrupt_rate)
	{
		int spot = (int)((double)rand() / RAND_MAX * len);
		if (debug)
			cout << "Packet was corrupted on the wire!  Byte " << spot <<  "is icky.\n";
		*(((char *)buf) + spot) = rand();
	}
	return sendto(fd, buf, len, flags, to, addr_len);
}

